package servlet;

import pojo.Student;
import service.StudentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
/**
 *2022.3.16测试完成，由李红玉编写
 * 更改学生状态
 */
@WebServlet(name = "StudentViolationServlet", value = "/StudentViolationServlet")
public class StudentViolationServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
        resp.setContentType("text/html; charset=utf-8");
        PrintWriter out=resp.getWriter();
        StudentService studentService=new StudentService();

        //保存结果变量
        int save=0;
        Student student=new Student();
        student.setStudentId(1001);
        student.setRecord(2);
        try {
            save=studentService.violation(student);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }

        out.println(save);
    }

}
